/// @tags: 
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

constexpr int maxn = 100;

char s[maxn + 1], t[maxn + 1];

int main() {
  int n;
  cin >> n;
  cin >> (s + 1) >> (t + 1);
  bool flag = true;
  for (int i = 1; i <= n; ++i) {
    if (s[i] != t[i]) {
      if ((s[i] == 'l' || s[i] == '1') && (t[i] == 'l' || t[i] == '1')) continue;
      if ((s[i] == '0' || s[i] == 'o') && (t[i] == '0' || t[i] == 'o')) continue;
      flag = false;
    }
  }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("A - Similar String.in", "r", stdin);
  freopen("A - Similar String.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
